lib.use(['element', 'table', 'form','tablePlug','tree'], function () {
    var table = layui.table;
    var layer = layui.layer;
    var form = layui.form;
    var tree = layui.tree;
    //表格插件
    var uomTable;
    var pId=0;
    //初始表格基础参数
    table.set(common.layui.table.config());

    // 渲染表格
    uomTable = table.render({
              elem: '#reprocdefTable'
            , url: common.util.createUrl('/act/reprocdef/list')
            , cols: [[
                {type:'checkbox'}
               ,{type: 'numbers', title: '编号' }
               ,{ field: 'deploymentId',  hide: true }
               ,{ title: '部署编码', field: 'id'}
               ,{ title: '流程名称', field: 'name'}
               ,{ title: '流程编码', field: 'key'}
               ,{ title: '是否挂起', field: 'suspensionState'}
               ,{ title: '部署时间', field: 'deployTime'}
               ,{
                    field: 'id',fixed: 'right', title: '操作', width: 140, templet: function (row) {
                        return   '<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>';
                    }
                }
            ]]
    });
    //监听单元格事件
    table.on('tool(reprocdefTableFilter)', function (obj) {
        if (obj.event === 'del') {
            del(obj);
        }
        if(obj.event==='release'){
            common.ajax.get('/act/remodel/deploy?id='+obj.data.id, {}, function (resp) {
               common.util.success(resp.msg)
            })
        }
    });






    /**
     * 监听搜索条件提交事件
     */
    form.on('submit(searchFilter)', function(data){
        var param = data.field;
        searchTable(param)
        return false;
    });

    /**
     * 查询表格
     * @param params
     */
    function searchTable(params) {
        params=$.extend(params,common.from.serializeObject('#searchFrm'))
        uomTable.reload({where: params})
    }

    /**
     * 删除
     * @param params
     */
    function del(obj) {
        var id = obj.data.deploymentId;
        layer.confirm('真的删除吗', function(index){
            console.log('Menu Del param is', id);
            common.ajax.post('/act/reprocdef/delete/'+id, {}, function (resp) {
                searchTable();
                layer.close(index);
            })
        });
    }



});
